Fixed bug in hasMany relationship