resolved error, can still be improved in certain places