added bottom checking