simplefied some code that might have been the source for some strange bugs