fixing the bug found
finished merging and made some tweeks