Fixed errors. Tested in real life project