organized code, removed discrepanices