Took out some redundant code, more robust now.