Some improved logic