organized code better; removed exception from getFirst()