trimmed up some code