Add replace_item with function, remove os import
Fix whitespace errors