Fixed some basic logic