working exept for first condition :(