First solution attempt