Added logic and bonus problem