fixed more bugs in the code