adds cancel button
done refactoring
final refactoring