removing undefined index php error
refactoring the fix for undefined index php error