starting to work on minimize function