code rewritten, added mouse placement mode