Coming up with a logical and functional code