Updated code and added compatibly with any OS