cleanup up code and added messages