Working code without bonus task implemented