slightly cleaner impl