compacted code a bit