added proper messages, packed some functionality into methods