Fixed bug and migrated to bash buildin