refactored apikey
Added preferences