a bit cleaner code, fixed drawing