fixed bug in second task, improved third