added a -pedantic to gcc compile command and rewritten a more cleaner way some little pieces of code