added option for 32/64-bit system. Refactor code