Resolved all errors

Bug with last letter resolved;
Bug with spacing resolved;
Put function within an immediate function;