Finish functionality and clean code