Trimmed down code a little